package com.itheima.fanshe;

import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;

public class Demo01 {

    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<Student> clazz = Student.class;

//        Class<?> aClass = Class.forName("com.itheima.fanshe.Student");

      /*  Constructor<Student> constructor = clazz.getConstructor();
        Student student = constructor.newInstance();
        System.out.println(student);*/

     /*   Student student1 = clazz.newInstance();
        System.out.println(student1);*/

       // System.out.println(constructor);
        System.out.println("=====================");

        Constructor<?>[] constructors = clazz.getConstructors();
        System.out.println(Arrays.toString(constructors));
        System.out.println("=====================");
        Constructor<Student> declaredConstructor = clazz.getDeclaredConstructor(int.class);
        System.out.println(declaredConstructor);
        System.out.println("=====================");
        Constructor<?>[] declaredConstructors = clazz.getDeclaredConstructors();
        System.out.println(Arrays.toString(declaredConstructors));
        System.out.println("=====================");


        Constructor<Student> declaredConstructor1 = clazz.getDeclaredConstructor();
        declaredConstructor1.setAccessible(true);
        Student student2 = declaredConstructor1.newInstance();
        System.out.println(student2);

    }

}
